<template>
  <div class="table-page-search-wrapper">
    <el-form :inline="true" :model="form" ref="form">
      <el-row :gutter="24">
        <el-col :span="6">
          <el-form-item label="供应商" prop="supplierName">
            <el-input
              clearable
              @keyup.native.enter="handleSearch"
              placeholder="请输入名称"
              v-model="form.supplierName"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="类型" prop="supplierType">
            <el-select clearable v-model="form.supplierType" placeholder="请选择">
              <el-option
                v-for="item in supplierTypeArr"
                :key="item.value"
                :value="item.value"
                :label="item.title"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item>
            <el-tooltip class="item" effect="dark" content="查询" placement="top">
              <el-button type="primary" class="mr20" @click="handleSearch" icon="el-icon-search" />
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="重置" placement="top">
              <el-button @click="handleReset" icon="el-icon-refresh-right" />
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import { getDicData } from '@/utils/util'

export default {
  data() {
    return {
      form: {
        supplierName: null,
        supplierType: null,
        pageNo: 1
      },
      supplierTypeArr: []
    }
  },
  async mounted() {
    this.supplierTypeArr = getDicData('002', '002001')
  },
  methods: {
    handleSearch() {
      this.$emit('search', this.form)
    },
    handleReset() {
      this.$refs.form.resetFields()
      this.$emit('search', this.form)
    }
  }
}
</script>